package view;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Rectangle;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;

/**
 * The Class TaarifChangeGUI that extends AbstractGUI.
 * @author yudku
 */
public class TaarifChangeGUI   extends AbstractGUI
{
	
	/** The compensation label. */
	private JLabel compensationLabel = null;
	
	/** The service id. */
	private JLabel serviceID = null;
	
	/** The description. */
	private JLabel description = null;
	
	/** The price. */
	private JLabel price = null;
	
	/** The new price field. */
	private JTextField newPriceField=null;
	
	/** The reply button. */
	private JButton replyButton = null;	
	
	/** The content pane. */
	private JPanel contentPane=null;
	
	/** The wrn message. */
	private JLabel wrnMessage=null;
	
	/** The new price. */
	private JLabel newPrice=null;
	
	

	/**
	 * This is TaarifChangeGUI constructor.
	 * 
	 */
	public TaarifChangeGUI ()
	{ 		  
		
		super();
		
		 //taarif tDetails panel
		   contentPane=new JPanel();	
		  //Main Panel 
		   contentPane.setBorder(new TitledBorder(null, "Taarif change", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		   contentPane.setLayout(null);
		   contentPane.setOpaque(true);
		
		   contentPane.add(getserviceIDlabel());
		   contentPane.add(getdescriptionlabel());
		   contentPane.add(getpricelabel());
		   contentPane.add(getnewPrice());
		   contentPane.add(geReplyButton());
		   contentPane.add(getBackButton(),BorderLayout.SOUTH);
		   contentPane.add(getWrnMessage());
		   contentPane.add(getPpLabel());
	        

			  //Frame
		        this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		        this.setTitle("Compliant Deatails Window");
		        this.setContentPane(contentPane);  
		        
		       
		       
		        newPriceField.setColumns(10);
			    this.setLocationRelativeTo(null); //This will center the JFrame in the middle of the screen
		        this.setLocationByPlatform(true);
		        this.setSize(380, 300);         
	               
	  }
		
	/**
	 * This method initializes service id Label.
	 *
	 * @return the service i dlabel
	 */
	
	private JLabel getserviceIDlabel() {
		if (serviceID == null) {
			  serviceID = new JLabel(" ");
			   serviceID.setBounds(new Rectangle(56, 50, 150, 17));
			
		}
		return serviceID;
	}
	
	/**
	 * This method initializes descrition Label.
	 *
	 * @return the descriptionlabel
	 */
	private JLabel getdescriptionlabel() {
		if (description == null) {
			description = new JLabel(" ");
			   description.setBounds(new Rectangle(56, 70, 150, 17));
			  
		}
		return description;
	}
	
	/**
	 * This method initializes price Label.
	 *
	 * @return the pricelabel
	 */
	private JLabel getpricelabel() {
		if (price == null) {
			price = new JLabel(" ");
			price.setBounds(new Rectangle(56, 90, 150, 17));
			 
		}
		return price;
	}
	
	/**
	 * This method initializes price Label.
	 *
	 * @return the pp label
	 */
	private JLabel getPpLabel() {
		if (newPrice == null) {
			newPrice = new JLabel("New Price: ");
			newPrice.setBounds(new Rectangle(56, 130, 150, 17));
			 
		}
		return newPrice;
	}

	/**
	 * This method initializes new price Text Field.
	 *
	 * @return the new price
	 */
	private JTextField getnewPrice() {
		if (newPriceField == null) {
			 newPriceField = new JTextField();
		        newPriceField.setBounds(150, 130, 150, 17); 
		        newPriceField.setColumns(10);
		        newPriceField.setVisible(true);
		}
		return newPriceField;
	}
	
	
	/**
	 * This method initializes Send Button.
	 *
	 * @return the j button
	 */
	private JButton geReplyButton() {
		if (replyButton == null) {
			replyButton = new JButton();
			replyButton.setBounds(new Rectangle(56, 200, 106, 30));
			replyButton.setText("Send");
			
		}
		return replyButton;
	}
	

	/**
	 * This method creates warning message if currently is null.
	 * @return JLabel type.
	 */
	private JLabel getWrnMessage() {
		if (wrnMessage == null) {
			wrnMessage = new JLabel();
			wrnMessage.setForeground(Color.RED);
			wrnMessage.setBounds(70, 16, 320, 23);
			wrnMessage.setVisible(false);
		}
		return wrnMessage;
	}
	
	/**
	 * This method initializes Back Button.
	 *
	 * @return the back button
	 */
	private JButton getBackButton() {
		if (backButton == null) {
			backButton = new JButton();
			backButton.setBounds(new Rectangle(190, 200, 106, 30));
			backButton.setText("Back");
		
		}
		return backButton;
	}
	
	
	

	/**
	 * *********************************Public Methods.
	 *
	 * @param msg the msg
	 */
	
	/**
	 * This method display Warning Message.
	 * @param void	 
	 * */
	
	public void displayWrnMessage(String msg){
		wrnMessage.setText(msg);
		wrnMessage.setVisible(true);
	}
	
	/**
	 * This method return service ID.
	 *
	 * @return the service id
	 */
	public JLabel getserviceID() {
		
		return serviceID;
	}
	
	/**
	 * This method return description.
	 *
	 * @return the description
	 */
	public JLabel getdescription() {
	
		return description;
	}
	
	/**
	 * This method return lName Label.
	 *
	 * @return the price
	 */
	public JLabel getprice() {
		
		return price;
	}
	
	
	/**
	 * This method set JLablel Text genric.
	 *
	 * @param text the text
	 * @param label the label
	 */
	public void SetGenLabel(String text,JLabel label) {
		if (label != null) {

			label.setText(text);
		}
	}

	
	/**
	 * This method add action listener to Reply button.
	 *
	 * @param listener the listener
	 */
	public void addReplyActionListener(ActionListener listener){
		replyButton.addActionListener(listener);
	}
	
	/**
	 * Gets the price field.
	 *
	 * @return the price field
	 */
	public String getPriceField()
	{
		return newPriceField.getText();
	}
	
	
	/**
	 * This method return new price filed.
	 *
	 * @return the comp amount field
	 */
	public String getCompAmountField()
	{
		return newPriceField.getText();
	}
	
	/**
	 * This method return -simulate back button pressed .
	 */
	public void clickBackButton()
	{
		this.getBackButton().doClick();
	}
	
}